#ifndef QXGAME_CREATOR_H
#define QXGAME_CREATOR_H

#include <memory>
#include <unordered_map>
#include "SkillId.h"
#include "CharacterId.h"
#include "GameInfo.h"
#include "../object/hero/Succubus.h"
#include "../object/hero/Satan.h"
#include "../object/hero/Magician.h"
#include "../object/hero/Physician.h"
#include "../object/hero/Devil.h"
#include "../object/hero/Archer.h"
#include "../object/hero/SwordMan.h"
#include "../object/hero/WolfHime.h"
#include "../object/hero/Guard.h"
#include "../object/hero/Boar.h"
#include "../object/hero/Wolf.h"
#include "../object/hero/Slime.h"
#include "../object/hero/HoneyBee.h"
#include "../object/skill/Rasenshuriken.h"
#include "../object/skill/Discharge.h"
#include "../object/skill/Rasengan.h"
#include "../object/skill/Chidori.h"
#include "../object/skill/PurpleEnergy.h"
#include "../object/skill/WhirlWind.h"
#include "../object/skill/CobCannon.h"

class Creator {
public:
    static std::shared_ptr<Character> CreateCharacter(CharacterId id)
    {
        if (id == CharacterId::CHARACTER_SATAN) return std::make_shared<Satan>();
        if (id == CharacterId::CHARACTER_MAGICIAN) return std::make_shared<Magician>();
        if (id == CharacterId::CHARACTER_SUCCUBUS) return std::make_shared<Succubus>();
        if (id == CharacterId::CHARACTER_PHYSICIAN) return std::make_shared<Physician>();
        if (id == CharacterId::CHARACTER_ARCHER) return std::make_shared<Archer>();
        if (id == CharacterId::CHARACTER_BOAR) return std::make_shared<Boar>();
        if (id == CharacterId::CHARACTER_DEVIL) return std::make_shared<Devil>();
        if (id == CharacterId::CHARACTER_GUARD) return std::make_shared<Guard>();
        if (id == CharacterId::CHARACTER_HONEYBEE) return std::make_shared<HoneyBee>();
        if (id == CharacterId::CHARACTER_SLIME) return std::make_shared<Slime>();
        if (id == CharacterId::CHARACTER_SWORDMAN) return std::make_shared<SwordMan>();
        if (id == CharacterId::CHARACTER_WOLF) return std::make_shared<Wolf>();
        if (id == CharacterId::CHARACTER_WOLFHIME) return std::make_shared<WolfHime>();
        return nullptr;
    }

    static std::shared_ptr<Character> CreateHero(CharacterId id)
    {
        std::shared_ptr<Character> hero = CreateCharacter(id);
        auto& heroInfo = GameInfo::Instance().heroInfoPool[id];
        hero->speed = heroInfo.speed;
        hero->maxSpeed = heroInfo.maxSpeed;
        hero->hp = heroInfo.hp;
        hero->maxHp = heroInfo.maxHp;
        hero->mp = heroInfo.mp;
        hero->maxMp = heroInfo.maxMp;
        hero->recoverMp = heroInfo.recoverMp;
        hero->recoverHp = heroInfo.recoverHp;
        hero->shape.w = heroInfo.width;
        hero->shape.h = heroInfo.height;
        hero->attackShape.w = heroInfo.attackWidth;
        hero->attackShape.h = heroInfo.attackHeight;
        hero->damage = heroInfo.damage;
        return hero;
    }

    static std::shared_ptr<Skill> CreateSkill(SkillId id)
    {
        if (id == SkillId::SKILL_RASENGAN) return std::make_shared<Rasengan>();
        if (id == SkillId::SKILL_DISCHARGE) return std::make_shared<Discharge>();
        if (id == SkillId::SKILL_RASENSHURIKEN) return std::make_shared<Rasenshuriken>();
        if (id == SkillId::SKILL_CHIDORI) return std::make_shared<Chidori>();
        if (id == SkillId::SKILL_PURPLE_ENERGY) return std::make_shared<PurpleEnergy>();
        if (id == SkillId::SKILL_WHIRL_WIND) return std::make_shared<WhirlWind>();
        if (id == SkillId::SKILL_COB_CANNON) return std::make_shared<CobCannon>();
        return nullptr;
    }
};

#endif //QXGAME_CREATOR_H
